import React, { Component } from 'react'
import {Link} from "react-router-dom";
import store from '../store/index'
export default class Home extends Component {
    constructor(props){
        super(props)
        this.state = store.getState()
        store.subscribe(()=>{
            this.setState(store.getState())
        })
    }
    render() {
        return (
            <div>
                <Link to="/city">{this.state.msg}</Link>
                <button onClick={this.changeState}>更改state</button>
            </div>
        )
    }
    changeState=()=>{
        var action={
            type:'btn_change',
            value:'更改redux'
        }
        store.dispatch(action)
    }
}
